// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWidgets headers)
#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif

#include "DRenderFrame.h"

BEGIN_EVENT_TABLE(DRenderFrame, wxPanel)
	EVT_SIZE(DRenderFrame::OnSize)
	EVT_RIGHT_DOWN(DRenderFrame::OnMouseRButtonDown)
	EVT_RIGHT_UP(DRenderFrame::OnMouseRButtonUp)
	EVT_LEFT_DOWN(DRenderFrame::OnMouseLButtonDown)
	EVT_LEFT_UP(DRenderFrame::OnMouseLButtonUp)
END_EVENT_TABLE()

DRenderFrame::DRenderFrame(wxWindow *parent) :wxPanel(parent, 0, 0, 0, 0)
{
	engine = NULL;
}

DRenderFrame::~DRenderFrame(void)
{
}


void DRenderFrame::OnSize(wxSizeEvent &evt)
{
	wxPanel::OnSize(evt);

	if(engine != NULL)
	{
		wxSize wx = evt.GetSize();
		
		engine->SetWindowSize(wx.GetWidth(), wx.GetHeight());

		engine->OnResize();
	}
}

void DRenderFrame::OnMouseLButtonDown(wxMouseEvent &evt)
{
	if(engine != NULL)
	{
		engine->m_viewCam.cameraControl = true;
		static wxPoint wp;
		wp = evt.GetPosition();
		wxWindow::ClientToScreen(&wp.x, &wp.y);

		engine->m_control.SetMousePoint(&wp.x, &wp.y);
	}
	//
}

void DRenderFrame::OnMouseLButtonUp(wxMouseEvent &evt)
{
	if(engine != NULL)
		engine->m_viewCam.cameraControl = false;
}

void DRenderFrame::OnMouseRButtonDown(wxMouseEvent &evt)
{
	/*wxMenu *menu = new wxMenu();

	menu->Append(-1, _("Test1"));
	menu->Append(-1, _("Test2"));
	menu->Append(-1, _("Test3"));
	menu->Append(-1, _("Test4"));*/

	//menu->

}

void DRenderFrame::OnMouseRButtonUp(wxMouseEvent &evt)
{
	//
}